package com.siyu.core.manager;

import java.util.List;

import com.siyu.common.email.EmailSender;
import com.siyu.common.email.MessageTemplate;
import com.siyu.common.page.Pagination;
import com.siyu.common.security.BadCredentialsException;
import com.siyu.common.security.UsernameNotFoundException;
import com.siyu.tickets.entity.SysUser;

public interface SysUserMng {

	public SysUser login(String username, String password, String ip) throws UsernameNotFoundException,
			BadCredentialsException;

	public boolean usernameExist(String username);

	public boolean emailExist(String email);

	public void updateLoginInfo(Integer userId, String ip);

	public SysUser getByUsername(String username);

	public List<SysUser> getByEmail(String email);

	public Pagination getPage(int pageNo, int pageSize);

	public Pagination getPage(String username, String realname, String deptname, Integer typeId, Boolean activation,
			Integer orderBy, int pageNo, int pageSize);

	public SysUser findById(Integer id);

	public SysUser save(String username, String realname, String email, String password, String ip);

	public SysUser save(String username, String realname, String email, String password, String ip, Boolean activation);

	public SysUser save(String username, String realname, String email, String password, String ip,
			Boolean activation, EmailSender sender, MessageTemplate msgTpl);

	/**
	 * 修改邮箱和密码
	 * 
	 * @param id
	 *            用户ID
	 * @param password
	 *            未加密密码。如果为null或空串则不修改。
	 * @param email
	 *            电子邮箱。如果为空串则设置为null。
	 * @return
	 */
	public SysUser update(Integer id, String password, String email);

	/**
	 * 密码是否正确
	 * 
	 * @param id
	 *            用户ID
	 * @param password
	 *            未加密密码
	 * @return
	 */
	public boolean isPasswordValid(Integer id, String password);

	public SysUser deleteById(Integer id);

	public SysUser[] deleteByIds(Integer[] ids);

	public SysUser active(String username, String activationCode);

	public SysUser activeLogin(SysUser user, String ip);
}